{% extends "layout/normal/layout.twig" %}
{% block body %}
    {% if online_editor is defined %}
        {% if (online_editor=='KindEditor') %}
        <script>
        KindEditor.ready(function(KE) {
            KE.create('textarea[name="comment"]',{{ keConfig }});
        });</script>
        {% endif %}
        {% if (online_editor=='CKEditor') %}
        {{ editorHtml }}
        <script>$(function(){
             ckeditor_replace_comment();});</script>
         {% endif %}
         {% if (online_editor=='xhEditor') %}
        <script>$(function(){
            pageInit_comment();});</script>
        {% endif %}
    {% endif %}
    <div id="content" class="contentBox">
        <my:a href='{{ url_base }}?go={{ appName }}.auth.logout'><b>退出</b></my:a><br/>
        <my:a href="{{ url_base }}?go={{ appName }}.blog.display&pageNo={{ app.request.get('pageNo')|default('1') }}"><b>博客列表</b></my:a>
        <div id='blog{{ blog.blog_id }}' >
            <h3>{{ blog.blog_name }}</h3>
            <p>{{ blog.blog_content|raw|nl2br }}</p>
            评论数:{{ blog.count_comments }}
        </div>
        {% if (app.request.get('comment_id') is not defined) %}
            {% for comment in blog.comments %}
            <div>
                <blockquote>{{ comment.comment|raw|nl2br }} <br/>
                由 {{ comment.user.username }} 在 {{ comment.commitTime|date('Y-m-d H:i') }} 提交<br/><span></span>
                </blockquote>
                <b>
                {% if comment.canEdit %}[<my:a href="{{ url_base }}index.php?go={{ appName }}.comment.comment&comment_id={{ comment.comment_id }}&blog_id={{ comment.blog_id }}&pageNo={{ app.request.get('pageNo')|default('1') }}">改</my:a>]{% endif %}
                {% if comment.canDelete %}[<my:a href="{{ url_base }}index.php?go={{ appName }}.comment.delete&comment_id={{ comment.comment_id }}&blog_id={{ comment.blog_id }}&pageNo={{ app.request.get('pageNo')|default('1') }}">删</my:a>]{% endif %}
                </b>
            </div>
            {% endfor %}

        {% endif %}
        {% if blog.canEdit == false %}
        <div>
            <font color="{{ color|default('white') }}">{{ message|default("") }}</font><br/>
            {% if app.request.get('comment_id') is not defined %}<h2>提交新评论</h2> {% else %}<h2>修改评论</h2>{% endif %}
            <form name="commentForm" method="post">
                我要发言: <br/><input type="hidden" name="blog_id" value="{{ blog.blog_id }}"/>
                <textarea name="comment" id="comment" style="width:710px;height:300px;">{% if comment_content is defined %}{{ comment_content }}{% endif %}</textarea><br/>
                <input type="submit" value="提交" class="btnSubmit" /> <input class="btnSubmit" onclick="location.href=&quot;{{ url_base }}index.php?go={{ appName }}.comment.comment&blog_id={{ app.request.get('blog_id') }}&pageNo={{ app.request.get('pageNo')|default('1') }}&quot;" type="button" value="返回" />
            </form>
        </div>
        {% if (online_editor == "UEditor") %}
        <script>pageInit_ue_comment();</script>
        {% endif %}
        {% endif %}
    </div>
{% endblock %}
